package TwoAgain;

import java.util.Objects;

public class Commodity {
    private int code;
    private String name;
    private int Price;

    public Commodity(int code) {
        this.code = code;
    }


    public Commodity(int code, String name, int price) {
        this.code = code;
        this.name = name;
        Price = price;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPrice() {
        return Price;
    }

    public void setPrice(int price) {
        Price = price;
    }


    @Override
    public String toString() {
        return "Commodity{" +
                "code=" + code +
                ", name='" + name + '\'' +
                ", Price=" + Price +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Commodity commodity = (Commodity) o;
        return code == commodity.code;
    }

    @Override
    public int hashCode() {
        return Objects.hash(code);
    }
}
